package com.leadingsoft.web.service;

import java.util.ArrayList;
import java.util.List;

import org.pentaho.di.core.exception.KettleException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.leadingsoft.core.dto.BootTablePage;
import com.leadingsoft.core.mapper.KVariableDao;
import com.leadingsoft.core.model.KVariable;

@Service
public class VariableService {
    @Autowired
    private KVariableDao kVariableDao; 
    
    /**
     * @Title getList
     * @Description 获取作业参数列表
     * @return 
     * @throws KettleException
     * @return List<KQuartz>
     */
    public List<KVariable> getList(Integer uId){
        List<KVariable> resultList = new ArrayList<KVariable>();
        KVariable kVariable = new KVariable();
        kVariable.setDelFlag(1);
        kVariable.setAddUser(uId);
        resultList.addAll(kVariableDao.template(kVariable));        
        return resultList;
    }
    
    /**
     * @Title getList
     * @Description 获取分页列表
     * @param start 起始行数
     * @param size 每页行数
     * @param uId 用户ID
     * @return
     * @throws KettleException
     * @return BootTablePage
     */
    public BootTablePage getList(Integer start, Integer size, Integer uId){
        KVariable kVariable = new KVariable();
        kVariable.setDelFlag(1);
        kVariable.setAddUser(uId);
        List<KVariable> kQuartzList = kVariableDao.template(kVariable, start, size);
        long allCount = kVariableDao.templateCount(kVariable);
        BootTablePage bootTablePage = new BootTablePage();
        bootTablePage.setRows(kQuartzList);
        bootTablePage.setTotal(allCount);
        return bootTablePage;
    }   
}
